package top.ahwyy.controller.Action;

import java.io.IOException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;

import top.ahwyy.controller.impl.cardImpl;
import top.ahwyy.controller.inter.card;

public class cardsListAction implements ServletRequestAware, ServletResponseAware {

	public HttpServletResponse response;
	public HttpServletRequest request;
	public String pages;
	public String showNumber;
	
	public String execute(){

		response.setContentType("text/html;charset=utf-8");
		try {
			request.setCharacterEncoding("utf-8");
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		card ci = new cardImpl();
		
		int p = new Integer(pages);
		int s = new Integer(showNumber);
		
        String str = ci.getJsonCardsList(p, s);//"[{\"arg0\":\"arg0\",\"arg1\":\"json作者1\",\"arg2\":\"帖子主题2\",\"arg3\":\"分类\",\"arg4\":\"forumId\",\"arg5\":\"str\",\"arg6\":\"zanhref\",\"arg7\":\"赞数\",\"arg8\":\"评论href\",\"arg9\":\"评论数json\"},{\"arg0\":\"arg0\",\"arg1\":\"json作者\",\"arg2\":\"帖子主题\",\"arg3\":\"分类\",\"arg4\":\"forumId\",\"arg5\":\"str\",\"arg6\":\"zanhref\",\"arg7\":\"赞数\",\"arg8\":\"评论href\",\"arg9\":\"评论数json\"},{\"arg0\":\"arg0\",\"arg1\":\"json作者\",\"arg2\":\"帖子主题\",\"arg3\":\"分类\",\"arg4\":\"forumId\",\"arg5\":\"str\",\"arg6\":\"zanhref\",\"arg7\":\"赞数\",\"arg8\":\"评论href\",\"arg9\":\"评论数json\"}]";
        
		
		PrintWriter pw = null;
		try {
			pw = response.getWriter();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		pw.print(str);
		
		
		return null;
	}
	
	
	@Override
	public void setServletResponse(HttpServletResponse arg0) {
		// TODO Auto-generated method stub
		this.response = arg0;

	}

	@Override
	public void setServletRequest(HttpServletRequest arg0) {
		// TODO Auto-generated method stub
		this.request = arg0;

	}

}
